package com.kgis.map.events {
    import com.kgis.map.feature.Feature;
    import com.kgis.map.geometry.basetype.Extent;

    import flash.events.Event;
    import com.kgis.map.events.EventBase;

    /**
     * 设施事件
     */
    public class FeatureEvent extends EventBase {

        /**事件关联到的设施数组*/
        private var _features:Vector.<Feature> = null;

        /**
         * To know if ctrl key is pressed
         */
        private var _ctrlPressed:Boolean = false;

        private var _spec:Object = null;

        /**
         * Event type dispatched when the cursor is over a feature.
         */
        public static const FEATURE_OVER:String = "pkmap.featureover";

        /**
         * Event type dispatched when the cursor is leaving a feature.
         */
        public static const FEATURE_OUT:String = "pkmap.featureout";

        /**
         * Event type dispatched when a click occur on a feature.
         */
        public static const FEATURE_CLICK:String = "pkmap.featureclick";

        /**
         * Event type dispatched when a double click occur on a feature.
         */
        public static const FEATURE_DOUBLECLICK:String = "pkmap.featuredoubleclick";

        /**
         * Event type dispatched when left mouse button is down over a feature.
         */
        public static const FEATURE_MOUSEDOWN:String = "pkmap.featuremousedown";

        /**
         * Event type dispatched when left mouse button is up over a feature.
         */
        public static const FEATURE_MOUSEUP:String = "pkmap.featuremouseup";

        /**
         * Event type dispatched when the cursor is moving over a feature.
         */
        public static const FEATURE_MOUSEMOVE:String = "pkmap.featuremousemove";

        /**
         * Event type dispatched when one or more features are selected.
         */
        public static const FEATURE_SELECTED:String = "pkmap.featureselected";
        /**
         * 选择完抛出事件，供外部鼠标切换模式
         * */
        public static const FEATURE_SELECTBYBOX:String = "pkmap.featureselectbybox";
        /**
         * Event type dispatched when one or more features are unselected.
         */
        public static const FEATURE_UNSELECTED:String = "pkmap.featureunselected";

        public static const FEATURE_LOCATE_END:String = "pkmap.locate.end";

        /**
         * FeatureEvent constructor
         *
         * @param type event
         * @param active to determinates if the handler is active
         */

        public function FeatureEvent(type:String, feature:Feature, ctrlStatus:Boolean = false, bubbles:Boolean = false, cancelable:Boolean = false, bounds:Extent = null) {
            super(type, bubbles, cancelable);
            this.feature = feature;
            this._ctrlPressed = ctrlStatus;
        }

        override public function clone():Event {
            return this;
        }

        /**
         * Features concerned by the event. If only one feature is concerned, you should use the feature (without s) getter and setter.
         */
        public function get features():Vector.<Feature> {
            return this._features;
        }

        public function set features(value:Vector.<Feature>):void {
            this._features = value;
        }

        /**
         * Feature concerned by the event. If the event concern multiple features, the first one is returned.
         */
        public function get feature():Feature {
            return this._features[0];
        }

        public function set feature(value:Feature):void {
            var v:Vector.<Feature> = new Vector.<Feature>();
            v[0] = value;
            this._features = v;
        }

        /**
         * To know if ctrl key is pressed
         * @default false
         */
        public function get ctrlPressed():Boolean {
            return this._ctrlPressed;
        }

        public function get spec():Object {
            return _spec;
        }

        public function set spec(value:Object):void {
            _spec = value;
        }


    }
}

